import baseRequest from "@/utils/request";

/**
 * 重写request
 * @param config
 * @returns {Promise | Promise<unknown>}
 */
const request = function (config) {
  config.baseURL = process.env.VUE_APP_BASE_API + '/finance'
  return baseRequest(config)
}

/**
 * 获取财务的货件单
 * @param params
 * @returns {Promise|Promise<*>}
 */
export function getFinanceShipmentList(params = {}){
  return request({
    url: '/getFinanceShipmentList',
    params,
  })
}

/**
 * 获取货柜的成本
 * @param params
 * @returns {Promise|Promise<*>}
 */
export function getFinanceContainerList(params = {}){
  return request({
    url: '/getFinanceContainerList',
    params
  })
}

/**
 * 获取用户的结算货件单
 * @param params
 * @returns {Promise|Promise<*>}
 */
export function getUserShipmentFee(params = {}){
  return request({
    url: '/getUserShipmentFee',
    params
  })
}

/**
 * 生成用户的结算数据
 * @param data
 * @returns {Promise|Promise<*>}
 */
export function createUserFinanceShipment(data){
  return request({
    url: '/createUserFinanceShipment',
    data,
    method: 'post',
  })
}

/**
 * 获取代理的结算货柜
 * @param params
 * @returns {Promise|Promise<*>}
 */
export function getAgentContainerCost(params){
  return request({
    url: '/getAgentContainerCost',
    params,
  })
}


/**
 * 生成代理的结算单
 * @param data
 * @returns {Promise|Promise<*>}
 */
export function createAgentFinanceContainer(data){
  return request({
    url: '/createAgentFinanceContainer',
    data,
    method: 'post',
  })
}
